﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework3
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("PI的值为：{0}",PI(100 ));
            Console.ReadKey();
             
        }
        static double PI(int a)
        {
            double p=1.0;
            int b = 1;
            for (int i = 0; i < a-1; i++)
            {
                b= -b;
                p =p+ b * (1.0 / (2 * (i + 1) + 1));
               
            }
            return 4*p;
        }
    }
}
